package org.example.bookstore.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.example.bookstore.pojo.DO.Order;
import org.example.bookstore.pojo.DTO.CommentUser;
import org.example.bookstore.pojo.DTO.DetailOrder;

import java.util.List;

@Mapper
public interface OrderMapper {
    /*
     * 订单添加
     * */
    @Insert("INSERT INTO `order` (userId, bookId, adressId, bookNum, orderType, totalPrice, payMethod, payStatus, createTime, updateTime) " +
            "VALUES (#{userId}, #{bookId}, #{adressId}, #{bookNum}, #{orderType}, #{totalPrice}, #{payMethod}, #{payStatus}, #{createTime}, #{updateTime})")
    int addOrder(Order order);

    List<DetailOrder> selectOrdersByUserId(Integer id);

    /*
     * 根据评论id删除订单
     * */
    @Delete("DELETE FROM `order` WHERE id=#{id}")
    int deleteOrderById(Integer id);
}
